package com.oig.common.constants;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

public class CommonEnum {
    private CommonEnum(){}

    /**
     * 统一标志枚举
     * 0-false
     * 1-true
     */
    public enum FlagEnum{

        FALSE_FLAG("0"),
        TRUE_FLAG("1"),
        ;
        private final String code;
        public String getCode() {
            return code;
        }

        FlagEnum(String code){
            this.code = code;
        }

        public static boolean validCode(String code) {
            for (FlagEnum enumItems : FlagEnum.values()) {
                if (enumItems.getCode().equals(code)) {
                    return true;
                }
            }
            return false;
        }
    }

    /**
     * 统一单据状态码
     * 01-草拟
     * 02-待审核
     * 03-不通过
     * 04-正常
     * 05-删除
     */
    public enum CommonStatusEnum{
        INIT("01","草拟"),
        CHECKING("02","待审核"),
        UN_ENABLE("03","不通过"),
        OK("04","正常"),
        DEL("05","删除"),
        ;
        private final String code;
        private final String name;

        public String getCode() {
            return code;
        }
        public String getName() {
            return name;
        }

        CommonStatusEnum(String code, String name){
            this.code = code;
            this.name = name;
        }

        public static String getNameByCode(String code){
            for(CommonStatusEnum statusEnum:CommonStatusEnum.values()){
                if (statusEnum.getCode().equals(code)) {
                    return statusEnum.getName();
                }
            }
            return  null;
        }

        public static boolean validCode(String code) {
            for (CommonStatusEnum enumItems : CommonStatusEnum.values()) {
                if (enumItems.getCode().equals(code)) {
                    return true;
                }
            }
            return false;
        }
    }


    /**
     * 分两种：
     * 一种变更是新生产条数据的，升级版本号的，如协议，报价，原记录就变更中 到已变更 （这个审核是在新记录里审核的，原记录只要记已变更）
     * 一种是另外做个变更表，存储变更数据的，原审核后覆盖原记录的，走 待提交 - 提交审核 -未变更
     *
     * 变更状态
     * 00-未变更
     * 01-变更待提交
     * 02-变更待审核
     * 03-变更不通过
     * 04-变更中
     * 05-已变更
     */
    public enum ChangeStatus {
        INIT("00","未变更"),
        CHANG_PRE("01","草拟变更"),
        CHANG_CHECK("02","变更待审核"),
        CHANG_REJECT("03","变更不通过"),
        CHANGING("04","变更中"),
        CHANGED("05","已变更"),
        ;
        private final String code;
        private final String name;

        public String getCode() {
            return code;
        }
        public String getName() {
            return name;
        }

        ChangeStatus(String code, String name){
            this.code = code;
            this.name = name;
        }
    }


    /**
     * 排序枚举
     * DESC
     * ASC
     */
    public enum SortEnum{
        DESC("DESC"), ASC("ASC");
        private final String code;
        public String getCode() {
            return code;
        }
        SortEnum(String code){
            this.code = code;
        }

        public static boolean validCode(String code) {
            for (SortEnum enumItems : SortEnum.values()) {
                if (enumItems.getCode().equals(code)) {
                    return true;
                }
            }
            return false;
        }
    }


    /**
     * 数据库操作枚举
     */
    public enum OperationEnum {
        insert, update, delete
    }



    /**
     * 主单据下可以用很多 相关的操作单据 需根据枚举配置
     *
     * 000-009为oigx框架自留
     */
    public enum RelationType{
        
        NIX("000","无"),
        OIGX_MSG("001","消息公共"),
        OIGX_TASK("002","任务"),
        OIGX_PORT("003","港口"),
        OIGX_HARBOR("004","口岸"),
        OIGX_CUSTOMS("005","海关"),
        OIGX_RATE("006","汇率"),
        OIGX_HS_GOODS("007","海关商品"),
        ;
        private final String code;
        private final String name;

        public String getCode() {
            return code;
        }
        public String getName() {
            return name;
        }

        RelationType(String code, String name){
            this.code = code;
            this.name = name;
        }
    }

    /**
     * 提交类型
     */
    public enum ReqType{
        INIT("0","草拟"),
        CHECKING("1","提交审核"),
        OK("2","提交生效")
        ;
        private final String code;
        private final String name;

        public String getCode() {
            return code;
        }
        public String getName() {
            return name;
        }

        ReqType(String code, String name){
            this.code = code;
            this.name = name;
        }
    }

    /**
     * 请求来源
     */
    @Getter
    public enum ReqSource{
        MANAGE("0","管理端"),
        CLIENT_WS("1","优顶特"),
        CLIENT_SAP("2","SAP"),
        ;
        private final String code;
        private final String name;

        ReqSource(String code, String name){
            this.code = code;
            this.name = name;
        }
    }

    /**
     * 启用/禁用
     */
    @Getter
    @AllArgsConstructor(access = AccessLevel.PRIVATE)
    public enum IsEnable{
        ENABLE("1","启用"),
        DISABLE("2","禁用")
        ;
        private final String code;
        private final String name;
    }

}
